#include <limits.h>
#include "../inc/Tools.h"

void getVectorCirclesBoundingBox ( vector <Circle> _circles, float& _aMin, float& _bMin, float& _rMin, float& _aMax, float& _bMax, float& _rMax )
{
	_aMin = (float)LONG_MAX;
	_bMin = (float)LONG_MAX;
	_rMin = (float)LONG_MAX;
	_aMax = (float)LONG_MIN;
	_bMax = (float)LONG_MIN;
	_rMax = (float)LONG_MIN;

	for ( int i = 0 ; i < (int)_circles.size() ; i++ )
	{
		if ( _aMin > _circles[i].getA() )
			_aMin = _circles[i].getA();

		if ( _bMin > _circles[i].getB() )
			_bMin = _circles[i].getB();

		if ( _rMin > _circles[i].getR() )
			_rMin = _circles[i].getR();

		if ( _aMax < _circles[i].getA() )
			_aMax = _circles[i].getA();

		if ( _bMax < _circles[i].getB() )
			_bMax = _circles[i].getB();

		if ( _rMax < _circles[i].getR() )
			_rMax = _circles[i].getR();
	}
}

float scalarProduct2D ( CVertexO _p1, CVertexO _p2 )
{
	return (_p1.P()[0]*_p2.P()[0] + _p1.P()[1]*_p2.P()[1]);
}


CVertexO diffPoint ( CVertexO _p1, CVertexO _p2 )
{
    CVertexO v;
    v.P()[0] = _p1.P()[0]-_p2.P()[0];
    v.P()[1] = _p1.P()[1]-_p2.P()[1];
    v.P()[2] = _p1.P()[2]-_p2.P()[2];
    return v;
}

bool compareVert(CVertexO* _v1, CVertexO* _v2)
{
    return _v1->P()[2] < _v2->P()[2];
}

